package com.mysiteforme.admin.controller.user;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.mysiteforme.admin.annotation.SysLog;
import com.mysiteforme.admin.dao.ElectricityCompanyDao;
import com.mysiteforme.admin.entity.ElectricityCompany;
import com.mysiteforme.admin.util.LayerData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.util.WebUtils;

import javax.servlet.ServletRequest;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 不可入市公司列表  前端控制器
 * </p>
 *
 * @author wangl
 * @since 2019-09-26
 */
@Controller
@RequestMapping("/admin/electricityNotEntryMarket")
public class ElectricityNotEntryMarketController {
    private static final Logger LOGGER = LoggerFactory.getLogger(ElectricityNotEntryMarketController.class);

    @Autowired
    private ElectricityCompanyDao electricityCompanyDao;

    @GetMapping("list")
    @SysLog("跳转不可入市公司列表")
    public String list(){
        return "/admin/electricityUserNotEnterMarker/list";
    }

    @PostMapping("list")
    @ResponseBody
    @SysLog("请求不可入市公司列表数据")
    public LayerData<ElectricityCompany> list(@RequestParam(value = "page",defaultValue = "1")Integer page,
                                              @RequestParam(value = "limit",defaultValue = "10")Integer limit,
                                              ServletRequest request){
        Map map = WebUtils.getParametersStartingWith(request, "s_");
        LayerData<ElectricityCompany> layerData = new LayerData<>();
        EntityWrapper<ElectricityCompany> wrapper = new EntityWrapper<>();

        List<ElectricityCompany> records = electricityCompanyDao.selectPageList(page, limit);
        Integer total = electricityCompanyDao.getCount();
        layerData.setData(records);
        layerData.setCount(total);
        return layerData;
    }
}
